class Solution(object):
    def searchRange(self, nums, target):
        """
        :type nums: List[int]
        :type target: int
        :rtype: List[int]
        """
        if len(nums)==0:
            return [-1,-1]
        left = 0
        right = len(nums)
        while left < right:
            mid = left + ((right-left)>>1)
            if nums[mid] < target:
                left = mid+1
            elif nums[mid] > target:
                right = mid-1
            else:
                left = mid
                break
        if left < 0 or left >= len(nums) or nums[left] != target:
            return [-1, -1]
        right = left
        while left >= 0 and nums[left]==target:
            left -= 1
        while right < len(nums) and nums[right]==target:
            right += 1
        return [left+1, right-1]

